'''
Created on Sep 16, 2010

@author: diego
'''
import cv
 

    

if __name__ == '__main__':
    capture=cv.CaptureFromCAM(1)
    frame=cv.QueryFrame(capture);
    gray=cv.CreateImage(cv.GetSize(frame), 8, 1)
    storage=cv.CreateMemStorage(0)
    params=(0,3000,3,1)
#    model=cv.LoadImage("book.jpg",cv.CV_LOAD_IMAGE_GRAYSCALE)
#    (modelKeypoints,modelDescriptors)=cv.ExtractSURF(gray, None, storage, params)
    while(True):
        frame=cv.QueryFrame(capture);
        cv.CvtColor(frame, gray, cv.CV_RGB2GRAY)
        (keypoints,descriptors)=cv.ExtractSURF(gray, None, storage, params)
        for ((x, y), laplacian, size, dir, hessian) in keypoints:
            print "x=%d y=%d laplacian=%d size=%d dir=%f hessian=%f" % (x, y, laplacian, size, dir, hessian)
            cv.Circle(frame, (x,y), size, (200,50,50))
        cv.ShowImage("surf", frame)
        cv.WaitKey(20)

def compare_surf(pt1,pt2):
    return True

def compare_desc(desc1,desc2):
    a=zip(desc1,desc2)
    for (x,y) in a:
        sum=sum + abs(x-y)
    return sum
    